import { Suspense, lazy } from 'react'
import Login from '@/pages/login'
import { Navigate } from 'react-router-dom'

const Entry = lazy(() => import('@/pages/entry'))
const Register = lazy(() => import('@/pages/register'))
const Home = lazy(() => import('@/pages/home'))
const LoadingPage = lazy(() => import('@/pages/loadingPage'))
const NotFound = lazy(() => import('@/pages/notFound'))


export const initialRouter = [
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/register',
    element: <Register />
  },
  {
    path: '/',
    element: (
      <Suspense fallback={ <LoadingPage /> }>
        <Entry />
      </Suspense>
    ),
    children: [
      {
        path: '/home',
        element: <Home />
      },
      {
        path: '/',
        element: <Navigate to='/home' />
      }
    ]
  },
  {
    path: '*',
    element: <NotFound />
  }
]
